package com.inspur.edp.ai.flow.engine;

import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.UUID;

/**
 * @author lizhaorui
 * @date 2025/8/15
 * @description 节点执行上下文
 */

@Data
public class FlowContext {


    private String flowMetadataId;

    /**
     * 流程实例Id
     */
    private String flowInstanceId;

    /**
     * 当前执行的流程
     */
    private Flow flow;
    /**
     * 是否需要流式输出
     */
    private Boolean streamOutput;


    private EventBus eventBus;

    private DataBus dataBus;

    public FlowContext(String flowMetadataId, String flowInstanceId) {
        this.flowMetadataId = flowMetadataId;
        this.flowInstanceId = flowInstanceId;
    }

    public String getFlowInstanceId() {
        if(StringUtils.isEmpty(this.flowInstanceId)) {
            this.flowInstanceId = UUID.randomUUID().toString();
        }
        return this.flowInstanceId;
    }
}
